package com.xysoft.framework.mvc;

import org.springframework.context.ApplicationListener;

import com.xysoft.framework.event.AbstractControllerEvent;
import com.xysoft.framework.event.ControllerAfterExecuteEvent;
import com.xysoft.framework.event.ControllerBeforeExecuteEvent;

public class ControllerListener implements ApplicationListener<AbstractControllerEvent> {

	@Override
	public void onApplicationEvent(AbstractControllerEvent event) {
		Object controller = event.getController();
		
		if(event instanceof ControllerAfterExecuteEvent) {
			
			System.out.println("Controller: + " + controller.getClass().getName() + ", Method: " + ((ControllerAfterExecuteEvent) event).getMethodName() +  ". 执行后");
			
		} else if(event instanceof ControllerBeforeExecuteEvent) {
			
			System.out.println("Controller: + " + controller.getClass().getName() + ", Method: " + ((ControllerBeforeExecuteEvent) event).getMethodName() +  ". 执行前");
			
		}
	}

}
